package com.zhengsr.latte.ec.ec.lunch;

import android.app.Activity;

import com.zhengsr.latte.delegates.LatteDelegate;
import com.zhengsr.latte.utils.SprefUtils;

/**
 * Created by zhengshaorui on 2018/4/30.
 */

public class BaseLunchActivity extends LatteDelegate{

    protected ILunchCallback mILunchCallback;
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof ILunchCallback){
            mILunchCallback = (ILunchCallback) activity;
        }
    }

    protected void checkUserSignIn(){
        //检测是否用户已经注册和是否有登录,助理方法在 app 的 mainactivity
        if (mILunchCallback != null){
            boolean isSignIn = (boolean) SprefUtils.getSprefValue(SprefUtils.ISSIGNIN, SprefUtils.SprefType.BOOLEAN);
            if (isSignIn){
                //登录则调用登录的接口
                mILunchCallback.onSignIn();
            }else{
                //没有则也调用
                mILunchCallback.onNotSignIn();
            }

        }
    }
}
